package edu.uow.devdocs
/**
 * The Issue entity.
 *
 * @author    
 *
 *
 */
class Issue {
    static mapping = {
         table 'ISSUE'
         // version is set to false, because this isn't available by default for legacy databases
         version false
         id column:'ISSUE_ID'
		 id generator: 'sequence', params:[sequence:'ISSUE_SEQ']
         project column:'SUB_SYSTEM_ID'
         status column:'STATUS_ID'
         person column:'PERSON_ID'
         issueType column:'ISSUE_TYPE_ID'
         downtimeReport column:'DOWNTIME_REPORT_ID'
		 deployment column:'DEPLOYMENT_ID'
		 sort dateCreated:'DESC'
    }

    String description
	java.math.BigDecimal priority = 3
	Date dateCreated
    java.math.BigDecimal estimatedHours
    String issue
    String referenceNumber
    Deployment deployment
    Date lastUpdated
    // Relation
    Project project
    // Relation
    IssueStatus status
    // Relation
    Person person
    // Relation
    IssueType issueType
    // Relation
    DowntimeReport downtimeReport
	List developmentTasks = new ArrayList()
	
	static searchable = {
		id name:'issue'}
	
	static hasMany = [
		developmentTasks: DevelopmentTask
	]
	
    static constraints = {
        priority(nullable: false, range: 1..5)
        dateCreated(nullable: true)
        description(size: 0..255)
        estimatedHours(nullable: true, size: 0..22)
        issue(nullable: true)
        referenceNumber(nullable: true,size: 0..20)
        deployment(nullable: true)
        lastUpdated(nullable: true)
        project()
        status()
        person()
        issueType()
        downtimeReport(nullable: true)
    }
    String toString() {
        return "${description.length() > 50 ? description.substring(0,50) + '....' : description}" 
    }
}
